/**
 * WidgetPropertyCommand
 */

  function WidgetPropertyCommand(page, oldWidget, newWidget, root, dataProvider){
      this.page = page;
      this.oldWidget = oldWidget;
      this.newWidget = newWidget;
      this.root = root;
      this.dataProvider = dataProvider;
      this.widgetId = this.oldWidget.id;
  };
  WidgetPropertyCommand.prototype = {
      execute: function() {

      },
      executeAction: function (type){
          var widget = this.dataProvider.getSpecifyWidgetById(this.widgetId);
          var actWidget = type === "undo" ? this.oldWidget : this.newWidget;
          widget = $.extend(true, widget, actWidget);
          widget.history = true;
          widget.property_changed = new Date();
          this.dataProvider.updateSpecifyWidget(widget, this.page.page_id, function (widgets){
              this.root.closeDialog();
              this.root.updateWidgets(widgets);
          }.bind(this));
      },
      undo: function() {
          //执行撤销操作
          this.executeAction("undo");
      },
      redo: function() {
          //执行重做操作
          this.executeAction("redo");
      }
  };

  module.exports = WidgetPropertyCommand;
